﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace KeyCtrl
{
    static class KeyUtils
    {
        public const int WM_KEYDOWN = 0x0100;
        public const int WM_KEYUP = 0x0101;
        public const int WM_HOTKEY = 0x0312;
        public const int WH_KEYBOARD_LL = 13;

        public enum KeyModifiers
        {
            None = 0,
            Alt = 1,
            Control = 2,
            Shift = 4,
            Windows = 8
        }

        public static KeyModifiers Key2Modifier(Keys key)
        {
            switch (key)
            {
                case Keys.Control:
                    return KeyModifiers.Control;
                case Keys.Alt:
                    return KeyModifiers.Alt;
                case Keys.Shift:
                    return KeyModifiers.Shift;
                case Keys.RWin:
                    return KeyModifiers.Windows;
                case Keys.LWin:
                    return KeyModifiers.Windows;
                default:
                    return KeyModifiers.None;
            }
        }

        // if you are going to use this implement the none modifier...
        //         public static Keys Modifier2Key(HotKey.KeyModifiers modifier, bool leftWindowsKey = true)
        //         {
        //             switch (modifier)
        //             {
        //                 case HotKey.KeyModifiers.Control:
        //                     return Keys.Control;
        //                 case HotKey.KeyModifiers.Alt:
        //                     return Keys.Alt;
        //                 case HotKey.KeyModifiers.Shift:
        //                     return Keys.Shift;
        //                 case HotKey.KeyModifiers.Windows:
        //                     if (leftWindowsKey)
        //                         return Keys.LWin;
        //                     return Keys.RWin;
        //             }
        //         }
    }
}
